﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;

namespace SendMail
{
    class Program
    {
        static void Main(string[] args)
        {
            var send = new MailSender();
            send.funcSend("11", "222");
        }
    }
    public class MailSender
    {
       

        public string propSmtpServer = "smtp.qq.com";
        public string propSmtpUID = "915222364@qq.com";
        public string propSmtpPWD = "";

        public string propMailFrom;
        public string propMailTo;

        public MailSender()
        {
            propMailFrom = propSmtpUID;
            propMailTo = "609722679@qq.com";
        }

        public void funcSend(string aSubject, string aBody)
        {
            try
            {
                SmtpClient client = new SmtpClient(propSmtpServer);

                client.UseDefaultCredentials = false;
                client.Credentials = new NetworkCredential(propSmtpUID, propSmtpPWD.Replace("8", ""));
                client.DeliveryMethod = SmtpDeliveryMethod.Network;

                MailAddress mail_from = new MailAddress(propMailFrom);
                MailAddress mail_to = new MailAddress(propMailTo);

                MailMessage message = new MailMessage(mail_from, mail_to);
                message.Sender = mail_from;
                message.BodyEncoding = System.Text.Encoding.UTF8;
                message.IsBodyHtml = true;

                message.Subject = aSubject;
                message.Body = aBody;

                client.Send(message);
            }
            catch (Exception ex)
            {

                throw;
            }

        }
    }
}